package cn.com.elite;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;


public class test2 {
	public static void main(String[] args) throws DocumentException{
		String responseStr="<PACKET><HEAD><REQUEST_TYPE>65</REQUEST_TYPE><RESPONSE_CODE>1</RESPONSE_CODE><ERROR_CODE>0000</ERROR_CODE><TRANS_MESSAGE>成功</TRANS_MESSAGE><TRANS_CODE>65000090812120300004</TRANS_CODE></HEAD><BODY><CANCELINFO_DTO><POA_CODE>100000076585</POA_CODE><OPERATER_CODE>55555</OPERATER_CODE><CANCEL_DTO_LIST><CANCEL_DTO><BUSINESS_NO>2180012242012000185</BUSINESS_NO></CANCEL_DTO><CANCEL_DTO><BUSINESS_NO>2180010022012000257</BUSINESS_NO></CANCEL_DTO></CANCEL_DTO_LIST></CANCELINFO_DTO></BODY></PACKET>";
		Document doc=DocumentHelper.parseText(responseStr); 
		Element root=doc.getRootElement(); 
		Element HEAD=root.element("HEAD"); 
		Element BODY=root.element("BODY");
		Element TRANS_CODE_Element=HEAD.element("TRANS_CODE");
		String TRANS_CODE=TRANS_CODE_Element.getText();
		System.out.println("TRANS_CODE:"+TRANS_CODE);
		Element CANCELINFO_DTO_Element=BODY.element("CANCELINFO_DTO");
		Element POA_CODE_Element=CANCELINFO_DTO_Element.element("POA_CODE");
		String POA_CODE=POA_CODE_Element.getText();
		System.out.println("POA_CODE:"+POA_CODE);
		Element OPERATER_CODE_Element=CANCELINFO_DTO_Element.element("OPERATER_CODE");
		String OPERATER_CODE=OPERATER_CODE_Element.getText();
		System.out.println("OPERATER_CODE:"+OPERATER_CODE);
		Element CANCEL_DTO_LIST_Element=CANCELINFO_DTO_Element.element("CANCEL_DTO_LIST");
		Iterator iters=CANCEL_DTO_LIST_Element.elementIterator();
		while(iters.hasNext()){
			Element CANCEL_DTO=(Element)iters.next();
			Element BUSINESS_NO_Element=CANCEL_DTO.element("BUSINESS_NO");
			String BUSINESS_NO=BUSINESS_NO_Element.getText();
			System.out.println("BUSINESS_NO:"+BUSINESS_NO);
		}
	}

}
